import java.util.*;

public class NoRepeatRandom
{
	private ArrayList<Integer> numList;
	private Random rand;
	
	public NoRepeatRandom()
	{
		numList = new ArrayList<Integer>();
		rand = new Random();
	}
	
	public int getNextInt(int max) throws Exception
	{
		if(numList.size() == max)
			throw new Exception("No more number");
		int temp = rand.nextInt(max);
		
		if(numList.isEmpty())
		{
			numList.add(temp);
		}
		else
		{
			while(numList.contains(temp))
			{
				temp = rand.nextInt(max);
			}
		}
		numList.add(temp);
		return temp;
	}
}